package com.cordys.opensource.crom;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * This interface can be implemented by objects that contain only master data in the database.
 * E.g., Person table contains only master data. If the domain object Ticket is inserted while containing
 * a Person, then the Person object will not be inserted into the database. Instead a relationship from
 * Ticket to the correct Person record is established.
 */
@Retention(RetentionPolicy.RUNTIME)
public @interface MasterData
{
	/**
	 * Returns the names of the columns that contain the unique values of the masterdata. These values
	 * must be filled when the MasterData object is created or when it is assigned to another object.
	 * E.g., for the crom.example.domain.Person master data object, this contains the "Email" column.
	 * "Name" is also the default value, as that is used mostly inside the database.
	 * @return
	 */
	String[] valueColumns() default {};
	
	/**
	 * If this returns true, then if the MasterData is not yet present in the database it will be inserted
	 * @return
	 */
	boolean isUpsertable() default false;
}
